package android.tvtt.yd360;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ListDrugFragment extends ListFragment {

	public ListDrugFragment() {
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		 // Initially there is no data 
        setEmptyText("No Data Here");

		String[] values = new String[] { "abacavir", "abatacept", "acarbose",
				"acebutolol", "aceclofenac", "acemetacin", "Acenocoumarol", "acetazolamide",
				"acetylcysteine", "acetylleucine","aciclovir" ,"acitretin","acrivastin",
				"activated charcoal","adalimumab","Adapalene","Adefovir dipivoxil","adenosine",
				"Adipiodone","albendazole"};
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1, values);
		setListAdapter(adapter);
		//getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		String item = (String) getListAdapter().getItem(position);
	    Toast.makeText(getActivity(), item + "", Toast.LENGTH_SHORT).show();
	    FragmentManager fragmentManager = getFragmentManager();
	    Fragment fragment = new DrugDetailFragment();
	    fragmentManager.beginTransaction()
				.replace(R.id.container, fragment).commit();
	}
}
